from pyquery import PyQuery

html = '''
    <html>
        <head>
            <title>PyQuery</title>
        </head>
        <body>
            <div id="main">
                <a href="www.baidu.com">百度网页</a>
                <h1>这个是百度网页<h1>
            </div>
            <h2>这个是百度网页<h2>
        </body>
    </html>
'''
doc = PyQuery(html)
# print(type(doc))
# print(doc)
# print(doc('title'))
# print(doc('#main'))
# 父节点
# print(doc('#main').parent())
# 子节点
# print(doc('#main').children())
# 兄弟节点
# print(doc('#main').siblings())
# 获取属性
# print(doc('a').attr('href'))
print(doc('#main').html())
print(doc('#main').text())
